package cn.est.controller;

import cn.est.dto.Result;
import cn.est.query.ModelQuery;
import cn.est.service.ModelService;
import cn.est.util.ResultUtil;
import cn.est.vo.ModelVO;
import cn.est.vo.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ModelController {
    @Autowired
    private ModelService modelService;

    @GetMapping("/api/model/search")
    public Result search(ModelQuery model) {
        PageVO<ModelVO> pageVO = modelService.listByPage(model);
        return ResultUtil.success(pageVO);
    }

    @GetMapping("/api/model/{id}/detail")
    public Result detail(@PathVariable Long id) {
        ModelVO pageVO = modelService.getModelById(id);
        return ResultUtil.success(pageVO);
    }
}
